﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using BarCode.Common;

namespace BarCode.Forms
{
    public partial class InputBox : Form
    {
        public InputBox()
        {
            InitializeComponent();
        }

        private void btnOk_Click(object sender, EventArgs e)
        {
            this.DialogResult = System.Windows.Forms.DialogResult.Yes;
            this.Close();
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
            this.Close();
        }

        public static string ShowInputBox()
        {
            InputBox box = new InputBox();
            DialogResult res = box.ShowDialog();
            if (DialogResult.Yes == res)
            {
                return box.txtInput.Text;
            }
            else
            {
                return Consts.CANCEL;
            }                               
        }

        private void txtInput_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == (char)13)
            {
                this.DialogResult = System.Windows.Forms.DialogResult.Yes;
                this.Close();
            }
        }

        private void InputBox_Load(object sender, EventArgs e)
        {
            txtInput.Focus();
        }

	
    }
}
